<?php 
require_once('./admin/View/video/inc_admin.php');
 ?>
        <!--PAGE CONTENT -->
        <div id="content">

            <div class="inner" style="min-height:1200px;">
                <div class="row">
                    <div class="col-lg-12">
<?php 

//编写sql语句
$sql="select comments.cid,comments.vid,comments.content,comments.uid,comments.cdate from comments join videos ON comments.vid=videos.vid";

$page=$_REQUEST['page'];
//判断是否指定第几页，如果没有指定，则显示第一页。
if(!isset($page))   $page=1;
//如果用户点击了搜索按钮，则页码也设置第一页
if($_POST['search']) $page=1;
//定义每页显示的行数
$rowsperpage=2;
//计算从表中第几行开始输出
$start=($page-1)*$rowsperpage;
//查询用户，从第$start行开始，共查询$rowsperpage行
$sql.=" limit {$start},{$rowsperpage}";
$result=mysql_query($sql)or die('查询失败！'.mysql_error());
 ?>


<marquee scrollamount="25">
<h3>留言列表</h3>
</marquee> 
<div class="container-fluid col-sm-offset-2 col-md-8">
<table align="center" class="table table-striped">
 
 	<tr class="success">
 		<th>序号</th>
 		<th>视频名称</th>
 		<th>留言内容</th>
 		<th>留言人</th>
 		<th>发表时间</th>
 		<th>操作</th>
 	</tr>
 	
 	<?php 
while ($row=mysql_fetch_assoc($result))
 {
	echo '<tr>';
	echo '<td>'.$row['cid'].'</td>';
	
	switch ($row['vid']) 
	{
		case '1':$vid="mmmmmm";break;
		case '2':$vid="wmmm";break;
		case '3':$vid="wm";break;
		case '4':$vid="mmpppp";break;
		case '5':$vid="mp5";break;
		case '6':$vid="blue";break;
		case '7':$vid="wmmwati";break;
		case '8':$vid="wm999";break;
		case '9':$vid="messy";break;
		default:$vid="不知道";
	}
	echo '<td>'.$vid.'</td>';
	echo '<td>'.$row['content'].'</td>';
	switch ($row['uid']) 
	{
		case '1':$uid="原来iiq";break;
		case '2':$uid="xiangqun99";break;
		case '3':$uid="xiangbo";break;
		case '4':$uid="sadsadsad";break;
		case '5':$uid="ppp";break;
		case '6':$uid="心墙";break;
		case '7':$uid="原来如此";break;
		case '8':$uid="mm";break;
		case '9':$uid="fo";break;
		case '10':$uid="nouse";break;
		case '11':$uid="ssss";break;
		default:$vid="不知道";
	}
	
	echo '<td>'.$uid.'</td>';
	echo '<td>'.$row['cdate'].'</td>';
	echo  '<td>
	 <a href="index.php?c=comment&m=delete&id='.$row['cid'].'" onClick="return confirm(\'确定要删除吗？\');" class="btn btn-danger">删除</a></td>';
	echo '</tr>';
}
	echo '</table>';
 	 //计算总页数。如果每页显示的行数>总行数，则只有1页，否则，页数=总行数/每页行数，上取整。
//echo $rowsperpage.','.$totalrows;
	if($rowsperpage>=$totalrows)
		$totalpages=1;
	else
	{
		$totalpages=ceil($totalrows/$rowsperpage);
	}
//如果不是第1页，则显示第一页和上一页的链接，否则只显示文字
	echo "<nav>";
    echo "<ul class='pager'>";
    
    
 
	if($page>1)

	{   echo "<li><a href=?page=1&key={$key}>首页</a></li>";
		echo "<li><a href=?page=".($page-1)."&key={$key}>上一页</a></li>";
        //$first="<a href=?page=1&key={$key}>首页</a>";
		//$pre="<a href=?page=".($page-1)."&key={$key}>上一页</a>";
	}else
	{
		echo "<li class='disabled'><a href='#'>首页</a></li>";
		echo "<li class='disabled'><a href='#'>上一页</a></li>";
//$first='首页';
//$pre='上一页';
	}
	//如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
	if($page<$totalpages)
		{   
			
	        echo "<li><a href=?page=".($page+1)."&key={$key}>下一页</a></li>";
	        echo "<li><a href=?page=$totalpages&key={$key}>尾页</a></li>";
		//$last="<a href=?page=$totalpages&key={$key}>尾页</a>";
		//$next="<a href=?page=".($page+1)."&key={$key}>下一页</a>";
	}else
	{
		echo "<li class='disabled'><a href='#'>尾页</a></li>";
		echo "<li class='disabled'><a href='#'>下一页</a></li>";
		//$last='尾页';
		//$next='下一页';
	}

 echo "</ul>";
echo "</nav>";

	 echo "<div class='text-center'>";
     echo "<ul class='pagination'>";
     echo "<li class='active'></li>";
	for($i=1;$i<=$totalpages;$i++)
	{       
     
     echo "<li><a class='num' href='?page=$i&key={$key}'>{$i}</a></li>";
 
	} 
	echo "<li><a class='next' href='?page=$i&key={$key}'>&gt;&gt;</a></li>";
	
	echo "<form method=post action='' class='form-search'>";
	echo "<tr><td><input type='text' name='page' placeholder='页码'' size=2 >";
	echo "<button type='submit' class='btn btn-info' >跳转</button></td></tr>";
	echo "</form>";
	
	echo "</ul>";
	echo "</div>";

	echo "<div class='text-right'>";
	echo "<table>";
	echo "<tr>共{$totalrows}条记录</tr>";
	echo "<td>&nbsp;&nbsp;$first"."&nbsp;&nbsp;"."$pre"."&nbsp;&nbsp;";
	echo "$next"."&nbsp;&nbsp;"."$last&nbsp;&nbsp";
	echo "</div>";
	//输出第几页/共几页
	echo "<font>";
	echo "<tr>&nbsp;&nbsp;&nbsp;第".$page."页/共".$totalpages."页</tr>";
	echo "&nbsp;&nbsp";
	echo "</font></td>";

	//输出转到几页的表单
	?>

	
    </table>


                   </div>
	             </div>
                </div>
            </div>
         </div>
    
    <div id="footer">
    <p>&copy;  binarytheme &nbsp;2014 &nbsp;</p>
    </div>
    <script src="assets/plugins/jquery-2.0.3.min.js"></script>
    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/plugins/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</body>
</html>
